cmake_minimum_required(VERSION 3.15)
project(UEStudio VERSION 1.0.0 LANGUAGES CXX DESCRIPTION "UEStudio - Modern C++ IDE")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# 编译选项
if(MSYS OR MINGW)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mconsole")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()

# 查找 wxWidgets
find_package(wxWidgets REQUIRED COMPONENTS core base aui propgrid stc ribbon)
include(${wxWidgets_USE_FILE})

# 包含目录
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/include/core
    ${CMAKE_CURRENT_SOURCE_DIR}/include/ui
    ${CMAKE_CURRENT_SOURCE_DIR}/include/projects
)

# 源文件
file(GLOB_RECURSE SOURCES 
    "src/core/*.cpp"
    "src/ui/*.cpp" 
    "src/projects/*.cpp"
    "src/editors/*.cpp"
)

file(GLOB_RECURSE HEADERS 
    "include/core/*.h"
    "include/ui/*.h"
    "include/projects/*.h" 
    "include/editors/*.h"
)

# 主可执行文件
add_executable(uestudio ${SOURCES} ${HEADERS})
target_link_libraries(uestudio ${wxWidgets_LIBRARIES})

# 安装目标
install(TARGETS uestudio DESTINATION bin)
install(DIRECTORY resources/ DESTINATION share/uestudio)

# 版本信息
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/include/core/Version.h.in
    ${CMAKE_CURRENT_BINARY_DIR}/include/core/Version.h
)
